报错信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[root@iZuf65vg2nr3x1h1yzuyq1Z bin]# ./shutdown.sh 
Using CATALINA_BASE: /usr/local/apache-tomcat-8.5.45
Using CATALINA_HOME: /usr/local/apache-tomcat-8.5.45
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.5.45/temp
Using JRE_HOME: /usr/local/jdk1.8.0_221/jre
Using CLASSPATH: /usr/local/apache-tomcat-8.5.45/bin/bootstrap.jar:/usr/local/apache-tomcat-8.5.45/bin/tomcat-juli.jar
Sep 11, 2019 9:15:54 PM org.apache.catalina.startup.Catalina stopServer
SEVERE: Could not contact [localhost:[8005]]. Tomcat may not be running.
Sep 11, 2019 9:15:54 PM org.apache.catalina.startup.Catalina stopServer
SEVERE: Catalina.stop:
java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.<init>(Socket.java:434)
at java.net.Socket.<init>(Socket.java:211)
at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:504)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:406)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:498)

解决办法:

执行vim shutdown.sh,编辑shutdown.sh脚本

修改前: exec "$PRGDIR"/"$EXECUTABLE" stop "$@"
修改后: exec "$PRGDIR"/"$EXECUTABLE" stop -force "$@"

执行vim catalina.sh,编辑catalina.sh脚本,在最前面添加以下代码

1
2
3
4
if [ -z "$CATALINA_PID" ]; then
CATALINA_PID=$PRGDIR/CATALINA_PID
cat $CATALINA_PID
fi